class Solution {
    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        int left = 0;
        int right = 0;
        while (right < n) {
            if (nums[left] == nums[right]) {
                nums[left] = nums[right];
            } else {

                nums[++left] = nums[right];
            }
            right++;
        }
        return left + 1;
    }
}